<?php

/**
 * Subclass for representing a row from the 'killmail' table.
 *
 * 
 *
 * @package lib.model
 */ 
class Killmail extends BaseKillmail
{
	function setContent($content)	{
		parent::setContent($content) ;
		
		$parts = explode("\n", $content) ;
		
		$date = $parts[0] ;
		$this->setKillDate(date('Y-m-d H:i:s', strtotime($date))) ;

		$parts = array_slice($parts, 1) ;
		$stop = false ;

		foreach ($parts as $lnum => $line)	{
			$key = trim(substr($line, 0, strpos($line, ":"))) ;
			$val = trim(substr($line, strpos($line, ":")+1)) ;

			switch ($key)	{
				case 'Victim':
					$this->setVictim($val) ;
					break ;
				case 'Alliance':
					$this->setAlliance($val) ;
					break ;
				case 'Corp':
					$this->setCorporation($val) ;
					break ;
				case 'Destroyed':
					$this->setDestroyed($val) ;
					break ;
				case 'System':
					$this->setSystem($val) ;
					break ;
				case 'Security':
					$this->setSecurity($val) ;
					break ;
				case 'Damage Taken':
					$this->setDamageTaken($val) ;
					break ;
				case 'Involved parties':
					$stop = true ;
					break ;
			}
			
			if ($stop)	{
				break ;
			}
		}
		
		$parts = array_slice($parts, $lnum) ;
		
		return true ;
	}
}
